#ifndef __DERIVEFXP_H__
#define __DERIVEFXP_H__

/** 
 * \brief 1st order derivative calculation
 *
 * Fixed sampling frequency 128Hz
 *
 * \ingroup Control
 *
 * \param[in] x input
 * \param z internal state
 *
 * \return L1_INT32 derivative
 */
static __inline L1_INT32 deriveFXP(L1_INT32 x, L1_INT32* z)
{
    L1_INT32 z0 = x << 7;

    L1_INT32 acc = z0 - (*z);    

    *z = z0;

    return acc;
}

#endif // __DERIVEFXP_H__
